var app = getApp()

const ourl = 'https://www.camphobby.com'

function request (url, method, data, header) {
  let promise = new Promise((resolve, reject) => {
    wx.showLoading({
      title:'加载中'
    })
    wx.request({
      url: ourl + url,
      method: method,
      data: {
        datas: data
      },
      header: header,
      success: res => {
        resolve(res)
      },
      fail: err => {
        reject(err)
      },
      complete: e => {
        wx.hideLoading()
      }
    })
  })
  return promise
}

module.exports = {
  request: request
}
